package com.prs.crm.action.purchase;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.courser.ui.PaginationSupport;

import com.prs.crm.action.FlowAction;
import com.prs.crm.annotation.Clew;
import com.prs.crm.annotation.FlowActive;
import com.prs.crm.annotation.FlowStart;
import com.prs.crm.context.AppContext;
import com.prs.crm.domain.purchase.Inquiry;
import com.prs.crm.domain.purchase.SupplierInquiry;
import com.prs.crm.domain.stock.Product;
import com.prs.crm.domain.stock.Supplier;
import com.prs.crm.service.purchase.InquiryService;
import com.prs.crm.service.purchase.SupplierInquiryService;


public class InquiryAction extends FlowAction<Inquiry> {

	private static final long serialVersionUID = -3081167964445727631L;
	private Inquiry inquiry;
	private Product product;
	private Supplier supplier;
	private InquiryService inquiryService;
	private Integer[] supplierIds;
	private Double[] price;
	private Double[] discount;
	private Double[] totalPrice;
	
	private PaginationSupport pagination;
	private SupplierInquiry supplierInquiry;
	private SupplierInquiryService supplierInquiryService;
	
	
	
	@Action("listSupplierInquiryFlow")
	public String listSupplierInquiry(){
		pagination = this.getPaginationHelper().prepare(pagination);
		pagination = this.getSupplierInquiryService().listFlowTask(SupplierInquiry.class, pagination, AppContext.getAccountContext().currentUser());
		return SUCCESS;
	}
	
	@FlowActive(target = "supplierInquiry", flowservice = "supplierInquiryService")
	@Action("editSupplierInquiryFlow")
	public String editSupplierInquiryFlow(){
		this.displayEndNodes();
		return SUCCESS;
	}
	@Clew(results={"success"})
	@FlowStart(target = "supplierInquiry", flowservice = "supplierInquiryService")
	@Action(value="submitSupplierInquiryFlow",results={@Result(name="success",type="redirect",location="listSupplierInquiryFlow")})
	public String submitSupplierInquiryFlow(){
		this.getSupplierInquiryService().execute(this.getNode(), this.getDetail(), supplierInquiry, AppContext.getAccountContext().currentUser());
		this.setPrompt("提交成功");
		return SUCCESS;
	}
	
	
	
	
	
	
	public Inquiry getInquiry() {
		return inquiry;
	}

	public void setInquiry(Inquiry inquiry) {
		this.inquiry = inquiry;
	}

	public Product getProduct() {
		return product;
	}

	public void setProduct(Product product) {
		this.product = product;
	}

	public Supplier getSupplier() {
		return supplier;
	}

	public void setSupplier(Supplier supplier) {
		this.supplier = supplier;
	}

	public InquiryService getInquiryService() {
		return inquiryService;
	}

	public void setInquiryService(InquiryService inquiryService) {
		this.inquiryService = inquiryService;
	}

	public Double[] getPrice() {
		return price;
	}

	public void setPrice(Double[] price) {
		this.price = price;
	}

	public Double[] getDiscount() {
		return discount;
	}

	public void setDiscount(Double[] discount) {
		this.discount = discount;
	}

	public Double[] getTotalPrice() {
		return totalPrice;
	}

	public void setTotalPrice(Double[] totalPrice) {
		this.totalPrice = totalPrice;
	}

	public Integer[] getSupplierIds() {
		return supplierIds;
	}

	public void setSupplierIds(Integer[] supplierIds) {
		this.supplierIds = supplierIds;
	}
	public PaginationSupport getPagination() {
		return pagination;
	}
	public void setPagination(PaginationSupport pagination) {
		this.pagination = pagination;
	}
	public SupplierInquiry getSupplierInquiry() {
		return supplierInquiry;
	}
	public void setSupplierInquiry(SupplierInquiry supplierInquiry) {
		this.supplierInquiry = supplierInquiry;
	}
	public SupplierInquiryService getSupplierInquiryService() {
		return supplierInquiryService;
	}
	public void setSupplierInquiryService(
			SupplierInquiryService supplierInquiryService) {
		this.supplierInquiryService = supplierInquiryService;
	}
	
	
	
	
}
